﻿@using Microsoft.AspNetCore.Http;
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewData["Title"] = "用户登录";
    Mango.Web.Common.WebSite webSite = new Mango.Web.Common.WebSite();
    Mango.Web.Models.WebSiteConfigModel configData = webSite.GetWebSiteData().WebSiteConfigData;
}

@if (configData.IsLogin)
{

    <div class="row " style="margin-top:30px;">
        <div class="col-lg-3 offset-5">
            <form class="form-horizontal" method="post" id="LoginForm" action="/account/login">
                <div class="form-group">
                    <input type="text" class="form-control" id="AccountName" name="AccountName" value="" placeholder="请输入手机号">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" id="Password" name="Password" value="" placeholder="请输入登陆密码">
                </div>
                <div class="form-group">
                    <div class="text text-red" id="messsage_Show">
                    </div>
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-lg btn-primary btn-block" id="btn_Post">马上登录</button>
                </div>

            </form>
        </div>

    </div>
}
else
{
    <div class="row">
        <div class="col-lg-2">

        </div>
        <div class="col-lg-8">
            <p class="text-center" style="font-size:15px;">
                因为系统调整暂时关闭登录功能,非常抱歉.
            </p>
        </div>
    </div>
}
@section Scripts{
    <script src="~/lib/jquery/jquery.validator.min.js"></script>
    <script src="~/lib/jquery/jquery.form.js"></script>
    <script type="text/javascript">
        var fromurl = "@(Html.ViewContext.HttpContext.Request.Query["fromurl"])";
        if (fromurl == "") {
            fromurl = "/portal";
        }
        $("#btn_Post").click(function () {
            var ths = this;
            var accountName = $("#AccountName").val();
            var password = $("#Password").val();
            if (accountName.trim() == "") {
                $("#messsage_Show").text("请输入电子邮箱");
            }

            else if (password.trim() == "") {
                $("#messsage_Show").text("请输入登录密码");
            }
            else {
                $(ths).addClass("disabled");
                $("#LoginForm").ajaxSubmit({
                    success: function (res) {
                        console.log(res);
                        if (res.code==0) {
                            window.location.href = fromurl;
                        }
                        else {
                            $("#messsage_Show").text(res.message);
                        }
                        $(ths).removeClass("disabled");
                    }
                });
            }
        });
    </script>
}